package org.framework.server.util.dao.sql.support;

import java.util.Map;

import org.framework.define.bean.result.criteria.Page;
import org.framework.server.util.dao.sql.support.sort.Sort;
import org.framework.server.util.dao.sql.support.sort.SortFilter;

public class Profile {
	
	private Page page;
	
	private SortFilter sortFilter;
	
	public Profile(Map<String,String> params) {
		this(new Page(params), new Sort(params));
	}
	
	public Profile(Page page, SortFilter sortFilter) {
		this.page = page;
		this.sortFilter = sortFilter;
	}
	
	public String toSortSql(String sql) {
		if(this.sortFilter !=null)
			return sql + " " + this.sortFilter.toSql();
		return sql;
	}
	
	public String toSortSql() {
		if(this.sortFilter ==null)
			return "";
		return this.sortFilter.toSql();
	}
	
	public Page getPage() {
		return page;
	}

	public void setPage(Page page) {
		this.page = page;
	}

	public SortFilter getSortFilter() {
		return sortFilter;
	}

	public void setSortFilter(SortFilter sortFilter) {
		this.sortFilter = sortFilter;
	}	
}
